package com.tiamo.traders.controller;

import com.tiamo.traders.entity.About;
import com.tiamo.traders.service.AboutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tiamo/about")
public class AboutController {
    @Autowired
    AboutService aboutService;

    @RequestMapping("/add")
    public int add(About about) {
        return aboutService.add(about);
    }

    @RequestMapping("/update")
    public int update(About about) {
        return aboutService.update(about);
    }

    @RequestMapping("/delete")
    public int delete(About about) {
        return aboutService.delete(about);
    }

    @RequestMapping("/findAll")
    public Map findAll(About about) {
        List<About> aboutList=aboutService.findAll(about);
        Integer count=aboutService.getCount(about);
        Map map=new HashMap();
        map.put("data",aboutList);
        map.put("count",count);
        return map;
    }

    @RequestMapping("/findById")
    public About findById(About about) {
        return aboutService.findById(about);
    }

    @RequestMapping("/getCount")
    public int getCount(About about) {
        return aboutService.getCount(about);
    }
}
